{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "380833f8",
   "metadata": {},
   "outputs": [],
   "source": [
    "\"\"\"\n",
    "获取宝塔面板\n",
    "\"\"\"\n",
    "\n",
    "# import pybtpanel\n",
    "\n",
    "import json\n",
    " \n",
    "\n",
    "from btapi import BTApi\n",
    "from comutils import get_main_domain_name_from_str\n",
    "\n",
    "DESKTOP = \"C:/users/Administrator/Desktop/\"\n",
    "SERVER_CONFIG = f\"{DESKTOP}/deploy_configs/server_config.json\"\n",
    "TEAM_JSON = r\"C:/sites/wp_sites/SpiderTeam.json\"\n",
    "DEFAULT_SERVER_NAME = \"server1\"\n",
    "TABLE_CONF = f\"{DESKTOP}/deploy_configs/table.conf\"\n",
    "\n",
    "\n",
    "def get_config(conf_path):\n",
    "    \"\"\"从配置文件中读取密钥\"\"\"\n",
    "    with open(conf_path, \"r\") as f:\n",
    "        data = json.load(f)\n",
    "    return data\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "if __name__ == \"__main__\":\n",
    "    # 读取宝塔密钥配置文件\n",
    "    config = get_config(SERVER_CONFIG)\n",
    "    auth = config[\"servers\"][DEFAULT_SERVER_NAME]\n",
    "    bt_key = auth[\"bt_key\"]\n",
    "    bt_url = auth[\"bt_panel\"]\n",
    "    # print(key,bt_url)\n",
    "\n",
    "\n",
    "    print(\"开始获取宝塔面板信息\")\n",
    "    api = BTApi(bt_url, bt_key)\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a942f794",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "31e00608",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "base",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
